<template>

  <el-form :inline="true" :model="userForm" class="demo-form-inline">
    <el-form-item label="账户">
      <el-input v-model="userForm.username"  clearable />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="userForm.password" show-password  clearable />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="login">登录</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import {reactive, inject, ref} from 'vue'
import {ElMessage} from 'element-plus'
import {loginService} from '@/api/user'
import router from "@/router";

const userForm=reactive({
   username:'',
   password:''
 });

const login=()=> {
  loginService(userForm).then(res=>{
    alert(0)
    if(res.code ==200){//登录成功
      sessionStorage.setItem("token",res.data);//存token到sessionStorage
      router.push("/list");
    }
  })
}
</script>

<style>

</style>